//物资采购结算 查看页面
<template>
    <!-- 集采汇总编辑页 -->
    <div class="e-form">
        <BillTop title="物资采购结算详情" @cancel="handleClose"></BillTop>
        <!-- //详情 添加页面 ↓ -->
        <div class="tabs">
            <el-tabs
                tab-position="left"
                v-model="tabsName"
                @tab-click="onChangeTab"
            >
                <!-- 基本信息 -->
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="结算明细"
                    name="planDetail"
                    :disabled="clickTabFlag"
                ></el-tab-pane>

                <el-tab-pane
                    label="服务费用"
                    name="fwfy"
                    :disabled="clickTabFlag"
                ></el-tab-pane>

                <el-tab-pane
                    label="保证金"
                    name="bzj"
                    :disabled="clickTabFlag"
                ></el-tab-pane>

                <el-tab-pane
                    label="附件信息"
                    name="accessory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>

                <el-tab-pane
                    label="审核历史"
                    name="auditHistory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>

                <!-- <el-tab-pane
          label="审核历史"
          name="auditHistory"
          :disabled="clickTabFlag"
        ></el-tab-pane> -->
                <div>
                    <!-- 基本信息 -->
                    <div id="baseInfoCon" class="con">
                        <div class="e-form">
                            <div class="tabs">
                                <div class="tabs-title" id="baseInfo">
                                    基本信息
                                </div>
                                <div style="width: 100%" class="form">
                                    <el-form
                                        ref="rulesBase"
                                        :model="formData"
                                        label-width="150px"
                                        :rules='rulesBase'
                                    >
                                        <el-row>
                                            <el-col
                                                :span="12"
                                            >
                                                <el-form-item
                                                    label="结算编号："
                                                    prop='billNo'
                                                >
                                                    <span>{{
                                                        formData.billNo
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="单据机构："
                                                    prop='orgName'
                                                >
                                                    <span>{{
                                                        formData.orgName
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="业务类型："
                                                    prop="businessType"
                                                >
                                                    {{ businessType }}
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="源单编号："
                                                >
                                                    <span>
                                                        {{
                                                            formData.sourceBillNo
                                                        }}
                                                        <i
                                                            slot="suffix"
                                                            class="
                                                                el-input__icon
                                                                el-icon-document-copy
                                                            "
                                                            @click="
                                                                sourceBillNoClick
                                                            "
                                                            v-if="
                                                                formData.sourceBillNo
                                                            "
                                                        ></i>
                                                    </span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="结算单位："
                                                    prop="settlementUnitName"
                                                >
                                                    <span>{{
                                                        formData.settlementUnitName
                                                    }}</span>
                                                    <!-- <el-input :disabled="true" v-model="formData.settlementUnitName"></el-input> -->
                                                    <!-- <el-button @click="xzjsmx">选择结算明细</el-button> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="结算日期："
                                                    prop="settlementDate"
                                                >
                                                    {{
                                                        formData.settlementDate
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="结算金额(元)："
                                                    prop='amount'
                                                >
                                                    {{formData.amount}}
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <!-- 返回id、名字 -->
                                                <el-form-item
                                                    label="经办人员："
                                                    prop='acceptancePersonnelName'
                                                >
                                                    <span>{{
                                                        formData.acceptancePersonnelName
                                                    }}</span>
                                                    <!-- <el-input :disabled="true" v-model="formData.acceptancePersonnelName"></el-input> -->
                                                    <!-- <el-button @click="xzry">选择</el-button> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="发票编号："
                                                    prop="invoiceNo"
                                                >
                                                    <span>{{
                                                        formData.invoiceNo
                                                    }}</span>
                                                    <!-- <el-input v-if="Thewas == 'add'" v-model="formData.invoiceNo"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="服务费用(元)："
                                                    prop='freight'
                                                >
                                                    <!-- <span>{{formData.freight}}</span> -->
                                                    <span>{{
                                                        formData.freight
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="税率%：" prop='taxRate'>
                                                    <span>{{
                                                        formData.taxRate
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="税价合计："
                                                     prop='totalAmount'
                                                >
                                                    <span>{{
                                                        formData.totalAmount
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="税额：" prop='taxAmount'>
                                                    <span>{{ formData.taxAmount }}</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="税额差额："
                                                >
                                                    <span>{{
                                                        formData.taxDifference
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="冲预付款金额(元)："
                                                >
                                                    <el-checkbox
                                                        v-model="
                                                            isOffsetAdvancePayment
                                                        "
                                                        disabled
                                                        @change="inputchanger3"
                                                    ></el-checkbox>
                                                    <span
                                                        style="
                                                            margin-right: 10px;
                                                        "
                                                    ></span>
                                                    <span>{{
                                                        formData.offsetAdvancePayment
                                                    }}</span>
                                                    <!-- <el-input :disabled="!formData.isOffsetAdvancePayment" v-model="formData.offsetAdvancePayment"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="单据来源："
                                                    prop='billSource'
                                                >
                                                    <span>{{
                                                        formData.billSource == 1
                                                            ? '新增'
                                                            : '验结一体'
                                                    }}</span>
                                                    <!-- <el-input v-model="formData.billSource"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col
                                                :span="12"
                                                v-if="
                                                    formData.businessType == '0'
                                                "
                                            >
                                                <el-form-item
                                                    label="冲个人借支："
                                                >
                                                    <el-checkbox
                                                        v-model="
                                                            isPersonalBorrowing
                                                        "
                                                        @change="inputchanger2"
                                                        disabled
                                                    ></el-checkbox>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="验收编号："
                                                    v-if='formData.billSource === 2'
                                                >
                                                    <span
                                                        style="
                                                            color: blue;
                                                            cursor: pointer;
                                                        "
                                                        @click="
                                                            acceptanceBillNoClick
                                                        "
                                                        >{{
                                                            formData.acceptanceBillNo
                                                        }}</span
                                                    >
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col
                                                :span="12"
                                                v-if="
                                                    formData.businessType == '0'
                                                "
                                            >
                                                <el-form-item
                                                    label="冲个人借支金额(元)："
                                                >
                                                    <span>{{
                                                        formData.personalBorrowing
                                                    }}</span>
                                                    <!-- <el-input  :disabled="!formData.isPersonalBorrowing"   v-model="formData.personalBorrowing"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="终期结算"
                                                >
                                                    <el-checkbox
                                                        v-model="isEndSettle"
                                                        disabled
                                                    ></el-checkbox>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col
                                                :span="12"
                                                v-if="
                                                    formData.businessType == '0'
                                                "
                                            >
                                                <el-form-item
                                                    label="冲销对象："
                                                >
                                                    <span>{{
                                                        formData.reversalObjectNumber
                                                    }}</span>
                                                    <!-- <el-input  :disabled="true" v-model="formData.reversalObjectNumber"></el-input> -->
                                                    <!-- <el-button  :disabled="!formData.isPersonalBorrowing" @click="xzcxdx">选择冲销对象</el-button> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="币种：">
                                                    <span>{{
                                                        formData.currency
                                                    }}</span>
                                                    <!-- <el-input v-model="formData.currency"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col
                                                :span="12"
                                                v-if="
                                                    formData.businessType == '0'
                                                "
                                            >
                                                <el-form-item
                                                    label="借支人员："
                                                >
                                                    <span>{{
                                                        formData.borrowerName
                                                    }}</span>
                                                    <!-- <el-input  :disabled="true" v-model="formData.borrowerName"></el-input> -->
                                                    <!-- <el-button  :disabled="!formData.isPersonalBorrowing" @click="xzjzry" >选择借支人员</el-button> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="本位币：" prop='baseCurName'>
                                                    <span>{{
                                                        formData.baseCurName
                                                    }}</span>
                                                    <!-- <el-input v-model="formData.baseCurName"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="本位币汇率："
                                                    prop="baseCurRate"
                                                >
                                                    <span>{{
                                                        formData.baseCurRate
                                                    }}</span>
                                                    <!-- <el-input v-model="formData.baseCurRate"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="人民币汇率："
                                                    prop='rmbRate'
                                                >
                                                    <span>{{
                                                        formData.rmbRate
                                                    }}</span>
                                                    <!-- <el-input v-model="formData.rmbRate"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="传财务共享："
                                                >
                                                    {{ formData.easId ? '已传' : '未传'}}
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="录入人：">
                                                    <span>{{
                                                        formData.founderName
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="24">
                                                <el-form-item label="备注：">
                                                    <span>{{
                                                        formData.remarks
                                                    }}</span>
                                                    <!-- <el-input type="textarea" :rows="2" laceholder="请输入内容" v-model="formData.remarks"></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="状态：">
                                                    <span>{{
                                                        state.find(
                                                            x =>
                                                                x.value ==
                                                                formData.state
                                                        ).label
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col
                                                :span="12"
                                                v-if="
                                                    formData.redBillState !== -1
                                                "
                                            >
                                                <!-- 仅发生冲红单业务时,才显示该字段,暂未做判断 -->
                                                <el-form-item label="冲红单">
                                                    <span
                                                        :style="
                                                            redBillStateStyle
                                                        "
                                                        >{{
                                                            redBillStateFun
                                                        }}</span
                                                    >
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row v-if="formData.state == 5">
                                            <el-col :span="12">
                                                <el-col :span="12">
                                                    <el-form-item
                                                        label="作废人："
                                                    >
                                                        <span>{{
                                                            formData.nullifyCreator
                                                        }}</span>
                                                    </el-form-item>
                                                </el-col>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="作废时间："
                                                >
                                                    <span>{{
                                                        formData.nullifyCreated
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>

                                        <el-row v-if="formData.state == 5">
                                            <el-col :span="12">
                                                <el-col :span="12">
                                                    <el-form-item
                                                        label="作废原因："
                                                    >
                                                        <span>{{
                                                            formData.nullifyReason
                                                        }}</span>
                                                    </el-form-item>
                                                </el-col>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="作废说明："
                                                >
                                                    <span>{{
                                                        formData.nullifyDescription
                                                    }}</span>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                    </el-form>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 结算明细 -->
                    <div id="planDetailCon" class="con">
                        <div class="tabs-title" id="planDetail">结算明细</div>
                        <div class="e-table">
                            <el-table
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                :data.sync="wzlbTableData"
                                ref='wzlbTable'
                                border
                                style="width: 100%"
                                :row-class-name="tableRowClassName"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect"
                                :tree-props="{
                                    children: 'children',
                                    hasChildren: 'hasChildren'
                                }"
                                default-expand-all
                                row-key="uuid"
                                :max-height="$store.state.tableHeight"
                                v-sortTable="{ 'tableData': wzlbTableData, '_this': this, 'ref': 'wzlbTable' }"
                            >
                                <el-table-column
                                    prop="materialClassName"
                                    label="物资类别"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="materialName"
                                    label="物资名称"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="spec"
                                    label="规格"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="texture"
                                    label="材质"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="unit"
                                    label="计量单位"
                                    width="100"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="warehouseName"
                                    label="仓库"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="acceptancePrice"
                                    label="验收单价"
                                    width="200"
                                >
                                </el-table-column>

                                <el-table-column
                                    prop="unsettledQuantity"
                                    label="未结算数量"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="settledQuantity"
                                    label="结算数量"
                                    width="100"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="acceptanceAmount"
                                    label="验收金额"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="settledPrice"
                                    label="结算单价(元)"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    label="结算金额(元)"
                                    width="100"
                                    prop="settledAmount"
                                >
                                </el-table-column>

                                <el-table-column
                                    prop="difference"
                                    label="差额"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="taxDifference"
                                    label="税额差额（元）"
                                    width="150"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <!-- 服务费用 -->
                    <div id="fwfyCon" class="con">
                        <div class="tabs-title" id="fwfy">服务费用</div>
                        <div class="e-table" style="min-height: auto">
                            <el-table
                                :data="serviceFeeData"
                                ref='serviceFeeTable'
                                border
                                style="width: 100%"
                                @selection-change="serviceFeeSelect"
                                :cell-class-name="cellClsNm"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                :max-height="$store.state.tableHeight"
                                v-sortTable="{ 'tableData': serviceFeeData, '_this': this, 'ref': 'serviceFeeTable' }"
                            >
                                <el-table-column type="selection" width="55">
                                </el-table-column>
                                <el-table-column
                                    label="合同编号"
                                    width="200"
                                    prop="contractBillNo"
                                    fixed
                                >
                                </el-table-column>
                                <el-table-column label="结算单位" width="200" prop='settlementUnitName' fixed>
                                </el-table-column>
                                <el-table-column label="发票编号" width="200" prop='invoiceNo'>
                                </el-table-column>
                                <el-table-column label="清单名称" width="200" prop='contractDtlName'>
                                </el-table-column>
                                <el-table-column label="数量" prop='quantity'>
                                </el-table-column>
                                <el-table-column
                                    prop="price"
                                    label="单价(元)"
                                ></el-table-column>
                                <el-table-column label="金额(元)" prop='amount'>
                                </el-table-column>
                                <el-table-column label="税率%" prop='taxRate'>
                                </el-table-column>
                                <el-table-column label="税额(元)" prop='taxAmount'>
                                </el-table-column>
                                <el-table-column
                                    prop="totalAmount"
                                    label="税额合计(元)"
                                    width="200"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <!-- 保证金 -->
                    <div id="bzjCon" class="con">
                        <div class="tabs-title" id="bzj">保证金</div>
                        <div class="lll">^ 暂扣保证金</div>
                        <div class="e-table" style="min-height: auto">
                            <el-table
                                :data="zkbzjtableData"
                                ref='zkbzjtable'
                                border
                                style="width: 100%"
                                :cell-class-name="cellClsNm"
                                :max-height="$store.state.tableHeight"
                                v-sortTable="{ 'tableData': zkbzjtableData, '_this': this, 'ref': 'zkbzjtable' }"
                            >
                                <el-table-column
                                    prop="returnDepositName"
                                    label="名称"
                                    width="270"
                                >
                                </el-table-column>
                                <el-table-column
                                    label="暂扣保证金(元)"
                                    width="150"
                                >
                                    <template v-slot="{ row }">
                                        <el-input
                                            v-model="row.amount"
                                            @input="zkbzjchange(row)"
                                        ></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    label="截止上期末暂扣保证金(元)"
                                    width="200"
                                >
                                    <template v-slot="{ row }">
                                        {{ row.previousTotalAmount }}
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    label="截止本期末暂扣保证金(元)"
                                    width="200"
                                >
                                    <template v-slot="{ row }">
                                        {{ row.currentTotalAmount }}
                                    </template>
                                </el-table-column>
                                <el-table-column label="说明" width="250">
                                    <template v-slot="{ row }">
                                        <el-input
                                            v-model="row.remarks"
                                        ></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                        <div class="lll">^ 返还保证金</div>
                        <div class="e-table" style="min-height: auto">
                            <el-table
                                :data="fhbzjtableData"
                                ref='multipleTable4'
                                border
                                style="width: 100%"
                                :cell-class-name="cellClsNm"
                                :max-height="$store.state.tableHeight"
                                v-sortTable="{ 'tableData': fhbzjtableData, '_this': this, 'ref': 'multipleTable4' }"
                            >
                                <el-table-column prop="returnDepositName" label="名称" width="270">
                                </el-table-column>
                                <el-table-column
                                    prop="amount"
                                    label="返还保证金(元)"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="previousTotalAmount"
                                    label="截止上期末未返还保证金(元)"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="currentTotalAmount"
                                    label="截止本期末未返还保证金(元)"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="remarks"
                                    label="说明"
                                    width="250"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                        <!-- <ComPagination /> -->
                    </div>

                    <!-- 附件信息 -->
                    <div id="accessoryCon" class="con">
                        <div class="tabs-title" id="accessory">附件信息</div>
                        <attach-comp
                            :relationId="attachId"
                            bucketName="materialsettle"
                            isView
                        />

                    </div>

                    <!-- 审核历史 -->
                    <div id="auditHistoryCon" class="con">
                        <div class="tabs-title" id="auditHistory">审核历史</div>
                                <ComAuditHistoryIndex
                                    :billType="1020"
                                    :tableData="shenheArr"
                                    @getAuditHistory="getauditHistory"
                                />
                    </div>
                </div>
            </el-tabs>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <div class="buttons" v-if="!isview">
            <el-button
                type="primary"
                style="background: #2e61d7"
                v-if="
                    formData.state == 2 &&
                    (formData.redBillState === '' ||
                        formData.redBillState === -1)
                "
                @click="chonghongdan"
                >冲红单</el-button
            >
            <!-- 这个打印需要单独写,因为有可能是验结一体的单子进入该页面,是可以打印,但是不能显示其他按钮 -->
            <el-dropdown
                size="small"
                type="primary"
                split-button
                @command="print"
                v-if="formData.state == 1 || formData.state == 2"
                >
                打印
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="command in commandList" :command="command.key" :key="command.key">{{command.value}}</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
            <exaButtons
                :auditState="auditState"
                :state="formData.state - 0"
                :founderId="formData.founderId"
                @exas="exas"
                v-if="formData.billSource !== 2 && formData.state !== 5"
            ></exaButtons>
            <el-button @click="handleClose">关闭</el-button>
        </div>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
import { mapMutations, mapState } from 'vuex'
import {
    showPromptPop,
    showSuccessPop,
    showLoading,
    hideLoading,
    openAppClient,
    selectDataClient,
    showErrorPop
} from '@/utils/common'

import { getUuid } from '@/utils/common'
import AttachComp from '@/components/common/attachIndex'
import planRequest from '@/api/turnover/plan.js'
// import { selectDataClient } from '@/utils/common'

import auditRequest from '@/api/materialSettlement/materialProcurement.js'
import publicRequest from '@/api/materialSettlement/public.js'

// import ComAuditHistoryIndex from '@/components/common/exaHistory.vue'
import ComAuditHistoryIndex from '@/pages/materialsmanagement/components/auditHistory/auditHistoryIndex'
// import {  showErrorPop } from '@/utils/common'
import exaButtons from '@/components/common/exaButtons'
// import historyUpdateTable from '@/components/common/historyUpdateTable'
import { webprintReport, numToChinese } from '@/utils/common'

export default {
    components: {
        AttachComp,
        ComAuditHistoryIndex,
        exaButtons
        // historyUpdateTable
    },
    data () {
        return {
            //我的数据:↓
            redBillStateStyle: {
                width: '300px',
                height: '30px',
                color: '#fff',
                backgroundColor: '',
                'text-align': 'center'
            },
            nullifyParams: {
                // 作废
                billId: this.$route.query.billid,
                billType: '1020',
                nullifyDescription: '',
                nullifyReason: '',
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: ''
            },
            Thewas: '',
            zkbzjtableData: [],
            fhbzjtableData: [],
            wzlbTableData: [],
            formData: {
                billNo: '', //	结算编号
                orgName: '', //机构name
                orgId: '', //机构id 不显示
                businessType: 0, //业务类型
                sourceBillNo: '', //源单编号
                sourceBillId: '', //元旦id 不显示
                settlementUnitName: '', //结算单位
                settlementUnitId: '', //结算单位id 不显示
                settlementDate: '', //结算日期
                amount: 0, //结算金额 元
                acceptancePersonnelName: '', //经办人员名称
                acceptancePersonnelId: '', //经办人人员id
                invoiceNo: '', //发票编号
                freight: 0, //运输服务费
                taxRate: 0, //税率
                totalAmount: 0, //税价合计
                taxAmount: 0, //税额
                taxDifference: 0, //税额差额
                billSource: 2, //单据来源(1:新增;2:颜结一体)
                billSourcetxt: '验结一体',
                isOffsetAdvancePayment: false, //是否冲预付款 需要转数字
                offsetAdvancePayment: null, // 	冲预付款金额(元)
                isPersonalBorrowing: false, //是否冲个人借资 需要转数字
                acceptanceBillNo: '', //验收编号
                personalBorrowing: 0, //	冲个人借资(元)
                // 1isPersonalBorrowing2personalBorrowing3reversalObjectNumber,reversalObjectId
                //4 borrowerName , borrowerId
                reversalObjectNumber: '', //	冲销对象编号
                reversalObjectId: '', //	冲销对象id 不显示
                currency: '', //币种名称
                currencyId: '', //币种id 不显示
                borrowerName: '', //借资人员名称
                borrowerId: '', //借资人员id 不显示
                baseCurName: '', //本位币名称
                baseCurId: '', //本位币id 不显示
                baseCurRate: 0, //本位币汇率 不显示
                baseCurAmount: 0, //结算金额(本位币)
                remarksL: '', //备注
                state: '0', //单据状态
                founderName: '', //创建人
                founderId: '', //创建人id 不显示
                rmbRate: 0,
                redBillState: null,
                isEndSettle: 0,
                acceptanceBillId: '',
                baseCurTaxAmount: 0,
                baseCurTotalAmount: 0,
                billId: '',
                currentTotalAmount: 0,
                difference: 0,
                easId: '',
                evaluationLevel: '',
                gmtCreate: '',
                gmtModified: '',
                isRed: 0,
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: '',
                purchasingUnitId: '',
                purchasingUnitName: '',
                remarks: '',
                rmbAmount: 0,
                rmbId: '',
                rmbName: '',
                rmbTaxAmount: 0,
                rmbTotalAmount: 0,
                sourceBillName: '',
                sourceId: '',
                sourceNumber: '',
                unoffsetAdvancePayment: null,
                workId: '',
            },
            typeArr: [
                { name: '零星采购计划', id: 0 },
                { name: '物资采购合同', id: 1 },
                { name: '调拔单', id: 2 }
            ],
            viewList: true,
            paginationInfo: {
                total: 1,
                pageSize: 10,
                currentPage: 0
            },
            query: {
                beginPlanDate: '',
                endPlanDate: '',
                keyword: '',
                limit: 0,
                orgId: '',
                page: 1,
                settlementUnitId: '',
                states: []
            }, //搜索
            searchKey: '', //右上角搜索关键字
            tableData: [], //表格
            shenheArr: [],
            serviceFeeData: [],
            serviceFeeData2: [],
            serviceFeeRow: {
                amount: 0, //金额元
                billId: '',
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: 0, //单价元
                quantity: 0, //数量
                settlementUnitId: '',
                settlementUnitName: '',
                taxAmount: 0, //税额元
                taxRate: 0, //税率%
                totalAmount: 0 // 税价合计
            },
            auditState: {},
            //我的数据:↑
            auditParams: {
                billId: this.$route.query.billid,
                billType: 1020,
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            },
            tabsName: 'baseInfo',
            userName: '',
            clickId: 'baseInfo',
            tabsNameChild: '',
            childTabClass: '',
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },

            OrgtableData: [], //申报机构数据
            OrgSonTableData: [], //申报机构子列表
            materialsTableData: [], //物资汇总数据
            auditHistoryList: [], //审核历史
            planSelect: [], //申报机构表格明细选择项
            value: '',
            textarea: '',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            MouseEnterId: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //基本信息表单数据
            basicFormData: {
                amount: null,
                billId: '',
                billNo: '',
                founderId: '',
                founderName: '',
                gmtCreate: '',
                gmtModified: '',
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: '',
                operator: '',
                operatorId: '',
                orgId: '',
                orgName: '',
                remarks: '',
                sourceBillId: '',
                sourceBillNo: '',
                sourceType: null,
                state: '',
                summaryDate: '',
                workId: ''
            },
            objFlag: {
                flag5: false
            },
            orgId: '', //机构id
            orgName: '', //机构名称
            billId: '',
            isSkip: false, //是否跳转
            show: true, //申报机构子列表
            dtlIds: '', //
            //验证
            rules: {
                summaryDate: [
                    {
                        required: true,
                        message: '请输入汇总日期',
                        trigger: 'blur'
                    }
                ],
                currencyId: [
                    { required: true, message: '请选择币种', trigger: 'chenge' }
                ]
            },
            materialsNameData: [], //机构汇总表
            createHistoryData: [], //明细修改历史列表
            errorMsg: [],
            isErrorMsg: true, //是否提醒错误信息
            //我的字段 ↓
            user: '', //当前用户

            //我的字段 ↑
            isview: false, // 如果是别的页面弹出此页面,需要隐藏下面的按钮
            businessType: '',
            //验证
            rulesBase: {
                billNo: [
                    { required: true, message: '结算编号不能为空', trigger: 'change' }
                ],
                orgName: [
                    { required: true, message: '机构不能为空', trigger: 'change' }
                ],
                amount: [
                    { required: true, message: '结算金额不能为空', trigger: 'change' }
                ],
                settlementDate: [
                    { required: true, message: '结算日期不能为空', trigger: 'change' }
                ],
                businessType: [
                    { required: true, message: '业务类型不能为空', trigger: 'change' }
                ],
                settlementUnitName: [
                    { required: true, message: '结算单位不能为空', trigger: 'change' }
                ],
                acceptancePersonnelName: [
                    { required: true, message: '经办人员不能为空', trigger: 'change' }
                ],
                invoiceNo: [
                    { required: true, message: '发票编号不能为空', trigger: 'change' }
                ],
                taxRate: [
                    { required: true, message: '税率不能为空', trigger: 'change' }
                ],
                taxAmount: [
                    { required: true, message: '税额不能为空', trigger: 'change' }
                ],
                totalAmount: [
                    { required: true, message: '税价合计不能为空', trigger: 'change' }
                ],
                freight: [
                    { required: true, message: '服务费用不能为空', trigger: 'change' }
                ],
                billSource: [
                    { required: true, message: '单据来源不能为空', trigger: 'change' }
                ],
                baseCurRate: [
                    { required: true, message: '本位币汇率不能为空', trigger: 'change' }
                ],
                baseCurName: [
                    { required: true, message: '本位币不能为空', trigger: 'change' }
                ],
                rmbRate: [
                    { required: true, message: '人民币汇率不能为空', trigger: 'change' }
                ],

            },
            isOffsetAdvancePayment: 0,
            isPersonalBorrowing: 0,
            isEndSettle: 0,
            commandList: [
                { key: 1, value: '物资结算单' },
                { key: 2, value: '物资结算保证金暂扣/返还单' },
                { key: 3, value: '物资采购服务费结算单' },
            ],
            serviceFeeList: []
        }
    },
    async created () {
        this.billId = this.$route.query.billid
        let data = JSON.parse(localStorage.getItem('vuex'))
        this.orgId = data.userInfo.orgInfo.orgId
        this.user = JSON.parse(localStorage.getItem('vuex'))
        this.billId = this.$route.query.billid
        this.getBasicInfo()
        this.getSettlement()
        this.getServiceFee()
        this.getMargin()
        this.getCurrentUnitInfo()
    },
    watch: {
        'formData.redBillState' () {
            if (this.formData.redBillState == 3) {
                this.redBillStateStyle.backgroundColor = '#FF2300'
            } else if (
                this.formData.redBillState == 0 ||
                this.formData.redBillState == 1
            ) {
                this.redBillStateStyle.backgroundColor = '#FFA40D'
            } else if (this.formData.redBillState == 2) {
                this.redBillStateStyle.backgroundColor = 'rgb(153,153,153)'
            }
        }
    },
    methods: {
        ...mapMutations([
            'setPopConfirm',
            'setSelectedInfo',
            'setHistoryTableData',
            'setAuditParams'
        ]),
        // 获取基本信息
        async getBasicInfo () {
            this.formData = await auditRequest.getjibenxixibyId({ id: this.billId })
            if(this.formData.billSource == 2) {
            //单据来源(1:新增;2:颜结一体)
                this.formData.billSourcetxt = '验结一体'
            }else{
                this.formData.billSourcetxt = '新增'
            }
            if (this.formData.redBillState === 3) {
                // 说明当前是红单,需屏蔽按钮,输入框之类的
                this.isRedSingle = true
            }
            // 如果是3,说明进入该单据是红单进入到编辑页
            this.businessType = this.typeArr.find(
                item => item.id === this.formData.businessType
            ).name
            this.formData.currency = this.currencyForm.find(
                x => x.value == this.formData.currencyId
            ).label
            // 是否冲预付款
            this.formData.isOffsetAdvancePayment == 1 ? this.isOffsetAdvancePayment = true : this.isOffsetAdvancePayment = false
            // 是否冲个人借支
            this.formData.isPersonalBorrowing == 1 ? this.isPersonalBorrowing = true : this.isPersonalBorrowing = false
            // 是否终期结算
            this.formData.isEndSettle == 1 ? this.isEndSettle = true : this.isEndSettle = false
        },
        // 获取结算明细数据
        async getSettlement () {
            let wzlbTableData1 = await auditRequest.getmingxibyId({ id: this.billId })
            wzlbTableData1.forEach(item => {
                item.materialClassName = item.topClassName
                item.uuid = getUuid()
                item.isChecked = false
                item.children.forEach(i => {
                    i.uuid = i.dtlId
                    i.parentId = item.topClassId
                })
                const count = +(item.children
                    .reduce((prev, c) => (prev += +c.settledAmount || 0), 0))
                    .toFixed(2)
                item.materialName = `金额小计： ${count}`
            })

            this.wzlbTableData = wzlbTableData1
        },
        // 获取服务费用
        async getServiceFee () {
            this.serviceFeeData = await auditRequest.getfuwufeiyongbyId({ id: this.billId })
            if(this.serviceFeeData instanceof Array) {
                console.log('hishuzu1')
            }else{
                this.serviceFeeData = []
                console.log('889', this.serviceFeeData)
            }
        },
        // 获取保证金
        async getMargin () {
            this.bzjarr = await auditRequest.getbaozhenjinbyId({ id: this.billId })
            if(this.bzjarr.length > 0) {
                for(let i = 0; i < this.bzjarr.length ; i++) {
                    if(this.bzjarr[i].returnDepositType == 1) {
                    //暂扣保证金
                        this.zkbzjtableData.push(this.bzjarr[i])
                    }else{
                    //返还保证金
                        this.fhbzjtableData.push(this.bzjarr[i])
                    }
                }
            }
        },
        //我的方法 ↓
        async chonghongdan () {
            this.$router.replace({
                path: '/materialProcurementAdd',
                query: { isRedSingle: '1', billid: this.billId }
            })
            // await auditRequest.chonghongdan({ id: this.billId, billId: this.billId })
            // this.clientPop('suc', '冲红单成功')
            // this.$router.replace('/materialProcurementList')
        },
        async exas (arg) {
            if (arg === 'submit') {
                console.log('1') // 保存所有数据
                await this.submit()
            } else if (arg === 'submitCommit') {
                console.log('2') // 保存并提交
                await this.submitCommit()
            } else if (arg === 'audit') {
                console.log('3') // 审核
                await this.shenhe()
            } else if (arg === 'undoAudit') {
                await this.undoAudit() // 撤销审核
            } else if (arg === 'nullify') {
                console.log('5') // 作废(
                await this.zuofei()
            } else if (arg === 'deleteData') {
                console.log('6') // 删除
                await this.shanchu1()
            }
        },
        zuofei () {
            showLoading()
            hideLoading()
            this.setAuditParams(this.nullifyParams)
            // 客户端弹窗弹出本地页面
            openAppClient('/nullifyDialog', '单据作废原因', () => {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                // this.setSelectedInfo(auditParams)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                showLoading()
                publicRequest
                    .zuofei(auditParams)
                    .then(() => {
                        this.clientPop('suc', '作废成功', this.handleClose)
                    })
                    .finally(() => {
                        hideLoading()
                    })
            }, null, null, null, 'small')
        },
        async shanchu1 () {
            await auditRequest.shanchucgjs({ id: this.billId })
        },
        shenhe () {
            console.log('审核')
            openAppClient('/exaDialog', '填写审核意见', () => {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                // 将审核意见赋值给参数传给后端
                publicRequest
                    .goaudit({
                        billId: this.billId,
                        billType: '1020',
                        isPass: auditParams.isPass,
                        isShareInAudit: false,
                        opinion: auditParams.opinion
                    })
                    .then(() => {
                        this.clientPop('suc', '审核成功')
                        this.$router.replace('/materialProcurementList')
                    })
                    .catch(() => {
                        this.clientPop('suc', '审核失败')
                    })
            }, null, null, null, 'small')
        },
        async undoAudit () {
            this.clientPop('info', '确定返回上一步操作吗?', () => {
                showLoading()
                publicRequest.goBack(this.auditParams).then(() => {
                    hideLoading()
                    this.clientPop('suc', '撤回成功', this.handleClose)
                })
            })
        },
        chakan11 () {
            console.log(this.wzlbTableData)
        },
        zkbzjchange (row) {
            row.currentTotalAmount =
                row.previousTotalAmount - 0 + (row.amount - 0)
        },
        fhbzjAdd () {
            selectDataClient({
                SelectServiceToken:
                    '/materialsettle/purchaseSettlement/listUnreturnAmountForSelect', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: '0', // 接口参数(name为模拟参数)
                Title: '选择返还保证金' // 标题
            }).then(() => {
                // //保存用户选择返回数据到store
                // this.setSelectedInfo(val)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
            })
        },
        addzkbzj () {
            selectDataClient({
                SelectServiceToken: '/subcontract/basicSettingsBond/getBond', // 客户端对应方法名
                IsSingleMode: false, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: JSON.stringify({
                    orgId: '1439990097591140358',
                    contractCategoryName: '物资采购合同'
                }), // 接口参数(name为模拟参数)
                Title: '选择暂扣保证金' // 标题
            }).then(val => {
                //保存用户选择返回数据到store
                // this.zkbzjtableData = val
                for (let i = 0; i < val.length; i++) {
                    this.zkbzjtableData.push({
                        returnDepositName: val[i].name, //保证金名称
                        returnDepositId: val[i].billId, //保证金id
                        amount: 0, //暂扣保证金
                        previousTotalAmount: 0, //截止上期先固定写0
                        currentTotalAmount: 0, //截止本期
                        remarks: '', //备注
                        returnDepositType: 1 //1代表暂扣 2代表返还
                    })
                }
            })
        },
        gaibian (obj, type) {
            // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价

            if (type == '数量') {
                if (obj.unsettledQuantity < obj.settledQuantity) {
                    obj.settledQuantity = obj.unsettledQuantity
                    if (obj.settledAmount && obj.settledQuantity) {
                        console.log('进入判断')
                        obj.settledAmount = obj.settledAmount - 0
                        obj.settledQuantity = obj.settledQuantity - 0
                        obj.settledPrice =
                            obj.settledAmount / obj.settledQuantity - 0
                    } else {
                        console.log('2')
                        obj.settledPrice = 0
                    }
                    showErrorPop('结算数量不能超过未结算数量')
                }
            }
            console.log('1')
            console.log(obj.amount, '金额')
            console.log(obj.settlementUnit, '结算数量')
            console.log(obj.amount / obj.settlementUnit - 0, '计算')
            if (obj.settledAmount && obj.settledQuantity) {
                console.log('进入判断')
                obj.settledAmount = obj.settledAmount - 0
                obj.settledQuantity = obj.settledQuantity - 0
                obj.settledPrice =
                    (obj.settledAmount / obj.settledQuantity - 0).toFixed(2) -
                    0
                obj.taxDifference = obj.settledAmount - obj.acceptanceAmount

                // 差额  taxDifference 税额差额
            } else {
                console.log('2')
                obj.price = 0
            }
            console.log(obj)
        },
        addmx () {
            console.log('新增')
        },
        shuieheji (row) {
            if (
                row.taxRate - 0 > -999999 &&
                row.taxRate != 0 &&
                row.amount - 0 > -999999 &&
                row.amount != 0
            ) {
                row.taxAmount = (row.amount * (row.taxRate / 100)).toFixed(4)
                row.totalAmount = row.taxAmount - 0 + (row.amount - 0)
            }
        },
        //选择借支人员
        danjia (row, type) {
            console.log(row)
            console.log(type)
            if (
                row.amount - 0 > -999999 &&
                row.amount != 0 &&
                row.quantity - 0 > -999999 &&
                row.quantity != 0
            ) {
                row.price = (row.amount / row.quantity).toFixed(4)
                if (row.taxRate == 0) {
                    row.totalAmount = row.price
                }
            }
            // if(type == '数量') {

            //     if((row.amount - 0) > -999999 && row.amount != 0 && (row.quantity - 0) > -999999  && row.quantity != 0) {
            //         row.price = (row.amount / row.quantity).toFixed(4)
            //     }
            // }else{
            //     if((row.quantity - 0) > -999999  && row.quantity != 0) {
            //         row.price = (row.amount / row.quantity).toFixed(4)
            //     }
            // }
        },
        xzjzry () {
            //  borrowerName: '', //借资人员名称
            //  borrowerId: '', //借资人员id 不显示
            selectDataClient({
                SelectServiceToken: '/hr/user/getUserUnderOrgPage', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '借支人员选择' // 标题
            }).then(val => {
                // 保存用户选择返回数据到store
                // this.setSelectedInfo(val)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                if (val.length > 0) {
                    this.formData.borrowerName = val[0].userName
                    this.form.borrowerId = val[0].userId
                }
            })
        },
        //选择冲销对象
        xzcxdx () {
            // 弹窗选择数据
            selectDataClient({
                SelectServiceToken:
                    '/facilityconnect/lease/receive/plan/contract/receive', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: JSON.stringify({ name: '' }), // 接口参数(name为模拟参数)
                Title: '选择机构用户' // 标题
            }).then(val => {
                // 保存用户选择返回数据到store
                // this.setSelectedInfo(val)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                if (val.length > 0) {
                    this.formData.reversalObjectNumber = val[0].leaseUnit
                    this.form.reversalObjectId = val[0].leaseUnitId
                }
            })
        },
        chakand () {
            console.log(this.Thewas)
            console.log(this.Thewas != 'add')
        },
        inputchanger1 (e) {
            console.log('111', e)
            if (e == 2 || e == 3) {
                this.formData.isPersonalBorrowing = false
                this.formData.personalBorrowing = 0
                this.formData.reversalObjectNumber = ''
                this.formData.reversalObjectId = ''
                this.formData.borrowerName = ''
                this.formData.borrowerId = ''
            }
        },
        inputchanger2 (e) {
            console.log('111', e)
            if (e == false) {
                this.formData.personalBorrowing = 0
                this.formData.reversalObjectNumber = ''
                this.formData.reversalObjectId = ''
                this.formData.borrowerName = ''
                this.formData.borrowerId = ''
            }
        },
        inputchanger3 (e) {
            if (e == false) {
                this.formData.offsetAdvancePayment = 0
            }
        },
        tableRowClassNameF ({ row }) {
            if (row.changeType === -1) {
                return 'warning-row'
            }
            return ''
        },
        invoiceNoBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
        },
        contractDtlNameBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
        },
        // 数量变化时
        quantityBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            // // 不能超过合同数量
            if (row.quantitys) {
                if (row.quantity > row.quantitys) {
                    row.quantity = row.quantitys
                }
            }
            if (!!row.amount && !!row.quantity) {
                row.price = +row.amount / +row.quantity
            }
        },
        // 金额变化时
        amountBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.quantity) {
                row.price = +row.amount / +row.quantity
            }
            if (!!row.amount && !!row.taxRate) {
                row.taxAmount = row.amount * row.taxRate
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = row.amount + row.taxAmount
            }
            this.basicFormData.freight = this.serviceFeeData.reduce(
                (pre, c) => (pre += +c.amount || 0),
                0
            )
        },
        // 税率变化时
        taxRateBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.taxRate) {
                row.taxAmount = row.amount * row.taxRate
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = row.amount + row.taxAmount
            }
        },
        //税额变化时
        taxAmountBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = +row.amount + +row.taxAmount
            }
        },
        serviceFeeDelete (row, index) {
            // this.fuwufeiyongarr.splice(index, 1)
            row.changeType = -1
            row.amount = 0
            console.log(index)
            console.log(row)
            // this.serviceFeeData.splice(1, index)
            // this.serviceFeeData2.push(row)
        },
        async contractDialog (row, index) {
            let contracted = {
                contractId: row.contractBillId,
                contractType: row.contractBillType || 0
            }
            let res = await auditRequest.getContract(
                { orgid: this.orgId },
                contracted
            )
            let result
            // 如果选择的是合同并且合同下有清单,则需带入合同下的清单
            if (res.list && res.list.length > 0) {
                result = res.list.map(item => {
                    return {
                        amount: null,
                        // billId: this.billid,
                        billId: this.billid || '',
                        changeType: 1,
                        contractBillId: res.contractId,
                        contractBillNo: res.contractNumber,
                        contractDtlId: item.detailedId,
                        contractDtlName: item.name,
                        dtlId: '',
                        invoiceNo: '',
                        price: null,
                        quantity: item.quantity,
                        quantitys: item.quantity, // 这个字段是用于在修改数量时,不能大于合同数量的
                        settlementUnitId: res.secondPartyId,
                        settlementUnitName: res.secondPartyName,
                        taxAmount: null,
                        taxRate: res.taxRate,
                        totalAmount: null
                    }
                })
                let _arr = []
                result.forEach(item => {
                    const shouldPush = this.serviceFeeData.every(
                        it => item.contractDtlId !== it.contractDtlId
                    )
                    if (shouldPush) {
                        _arr.push(item)
                    } else {
                        // 找到了清单ID相同
                        const repeatArr = this.serviceFeeData.filter(
                            i => item.contractDtlId === i.contractDtlId
                        )
                        const noPush = repeatArr.some(
                            _its => _its.changeType !== -1
                        )
                        if (!noPush) {
                            _arr.push(item)
                        }
                    }
                })
                if (_arr.length !== 0) {
                    this.serviceFeeData.splice(index, 1, ..._arr)
                }
            } else {
                // 如果选择的合同没有清单
                result = {
                    amount: null,
                    billId: this.billid,
                    changeType: 1,
                    contractBillId: res.contractId,
                    contractBillNo: res.contractNumber,
                    contractDtlId: '',
                    contractDtlName: '',
                    dtlId: '',
                    invoiceNo: '',
                    price: null,
                    quantity: null,
                    settlementUnitId: res.secondPartyId,
                    settlementUnitName: res.secondPartyName,
                    taxAmount: null,
                    taxRate: res.taxRate,
                    totalAmount: null
                }
                const shouldPush = this.serviceFeeData.every(
                    it => it.contractBillId !== result.contractBillId
                )
                if (shouldPush) {
                    this.serviceFeeData.splice(index, 1, result)
                } else {
                    const repeatArr = this.serviceFeeData.filter(
                        i => i.contractBillId === result.contractBillId
                    )
                    const noPush = repeatArr.some(
                        _its => _its.changeType !== -1
                    )
                    if (!noPush) {
                        this.serviceFeeData.splice(index, 1, result)
                    }
                }
            }
        },
        async billingUnitDialog (row, index) {
            this.jsdwIds = row.settlementUnitId
            let res = await auditRequest.getBillingUnit(
                this.jsdwData,
                this.jsdwIds
            )
            // async getServeList () { // 弹窗好了,需删除这行
            //     let res = await request.getServeList(this.billingUnitQuery) // 弹窗好了,需删除这行
            let result = {
                amount: null,
                billId: this.billid,
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: null,
                quantity: null,
                settlementUnitId: res.id,
                settlementUnitName: res.outerName,
                taxAmount: null,
                taxRate: null,
                totalAmount: null
            }
            const shouldPush = this.serviceFeeData.every(
                it => it.settlementUnitId !== result.settlementUnitId
            )
            if (shouldPush) {
                this.serviceFeeData.splice(index, 1, result)
            } else {
                const repeatArr = this.serviceFeeData.filter(
                    i => i.settlementUnitId === result.settlementUnitId
                )
                const noPush = repeatArr.some(_its => _its.changeType !== -1)
                if (!noPush) {
                    this.serviceFeeData.splice(index, 1, result)
                }
            }
            this.basicFormData.freight = this.serviceFeeData.reduce(
                (pre, c) => (pre += +c.amount || 0),
                0
            )
        },
        serviceFeeAdd () {
            // this.serviceFeeData.push(this.serviceFeeRow)
            // 弹窗选择数据
            this.serviceFeeData.push({
                amount: 0, //金额元
                billId: '',
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: 0, //单价元
                quantity: 0, //数量
                settlementUnitId: '',
                settlementUnitName: '',
                taxAmount: 0, //税额元
                taxRate: 0, //税率%
                totalAmount: 0 // 税价合计
            })
        },
        // 复选框选中的数据
        serviceFeeSelect (selection) {
            this.serviceFeeList = selection
        },
        xzry () {
            selectDataClient({
                SelectServiceToken: '/hr/user/getUserUnderOrgPage', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '人员选择' // 标题
            }).then(val => {
                if (val.length > 0) {
                    this.$set(
                        this.formData,
                        'acceptancePersonnelName',
                        val[0].userName
                    )
                    this.$set(
                        this.formData,
                        'acceptancePersonnelId',
                        val[0].userId
                    )
                }
            })
        },
        //审核历史
        async getauditHistory () {
            console.log('1111111')
            if (this.billId !== '') {
                console.log('2222')
                const data = await publicRequest.getauditHistory({
                    billId: this.billId,
                    billType: 1020,
                    freeNextUnitIndex: 0,
                    freeNextUser: '',
                    isPass: true,
                    isShareInAudit: true,
                    opinion: ''
                })
                console.log('iop', data)
                // for(let i = 0 ; i < data.length ; i++) {
                //     this.shenheArr.push(data[i])
                // }
                this.shenheArr = [...data]
                console.log('xxx', this.shenheArr)
            }
        },
        async xzjsmx () {
            console.log('8888', this.user.userInfo.orgInfo.orgId)
            // const data =  await auditRequest.getjsmx({
            //     businessType: this.formData.businessType,
            //     // this.user.userInfo.orgInfo.orgId
            //     //  '1439990097591140354'
            //     orgId: this.user.userInfo.orgInfo.orgId,
            //     parentId: '0',
            //     settleUnitId: '',
            //     sourceBillId: ''
            // })
            // console.log(data, 'xxx')
            selectDataClient({
                SelectServiceToken:
                    '/materialsettle/acceptance/listUnsettleMaterialByFilterForSelect', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: JSON.stringify({
                    businessType: this.formData.businessType,
                    keyWord: '',
                    orgId: '1439990097591140358',
                    parentId: '0',
                    settleUnitId: '',
                    sourceBillId: ''
                }), // 接口参数(name为模拟参数)
                Title: '选择结算明细' // 标题
            }).then(val1 => {
                // 保存用户选择返回数据到store
                // this.setSelectedInfo(val1)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                if (val1.length > 0) {
                    this.father1 = val1[0]
                }
                let res = this.father1 //默认用户选择了第一个 模拟弹窗

                this.$set(
                    this.formData,
                    'settlementUnitName',
                    res.supplierName
                )
                this.$set(this.formData, 'settlementUnitId', res.supplierId)

                this.$set(this.formData, 'sourceBillNo', res.sourceBillNo)
                this.$set(this.formData, 'sourceBillId', res.sourceBillId)

                //接口还没更新 更新了 取消注释 ↓
                this.$set(this.formData, 'currency', res.currency)
                this.$set(this.formData, 'currencyId', res.currencyId)

                this.$set(this.formData, 'baseCurName', res.baseCurName)
                this.$set(this.formData, 'baseCurId', res.baseCurId)
                //接口还没更新 更新了 取消注释 ↑ 本位币 和 币种

                // if(res.currency == res.baseCurName) {
                //     this.$set(this.formData, 'taxRate', 1)
                // }

                //  sourceBillNo: '', //源单编号
                // sourceBillI:'',//元旦id 不显示

                // this.$set(this.formData, 'contractName', res.contractName)
                // this.$set(this.formData, 'contractBillNo', res.contractNumber)
                // this.$set(this.formData, 'contractBillId', res.contractId)

                // this.$set(this.formData, 'currency', res.currencyName)
                // this.$set(this.formData, 'currencyId', res.currencyId)

                // baseCurName: '', //本位币名称
                //     baseCurId: '', //本位币id
                //     baseCurRate: 0, //本位币汇率

                // const bwb = await bwbRequest.getBaseCyByOrgId({ orgId: this.user.userInfo.orgInfo.orgId })

                // this.$set(this.formData, 'baseCurName', res.currencyName)
                // this.$set(this.formData, 'baseCurId', res.recordId)
                // this.$set(this.formData, 'currencyId', data.currencyId)

                res = []

                for (let i = 0; i < val1.length; i++) {
                    if (val1[i].parentId != '0' && val1[i].parentId != 0) {
                        res.push(val1[i])
                    }
                }
                // res = [res]
                const mapObj = {}
                let arr = []
                res.forEach(e => {
                    // alert('1')
                    // this.setSelectedInfo(e)
                    // // 客户端弹窗预览结果
                    // // 参数依次为: 打开页面地址、标题、回调函数
                    // openAppClient('/showSelectedData', '选择结果', function () {
                    // // alert('关闭后回调')
                    // })
                    const children = []
                    e.materialClassNameArr = e.materialClassName.split('/')
                    e.materialClassIdArr = e.materialClassId.split('/')
                    // alert('111')
                    let obj
                    const topClassId = e.materialClassIdArr
                        .splice(0, 1)
                        .toString()
                    const topClassName = e.materialClassNameArr
                        .splice(0, 1)
                        .toString()
                    if (!mapObj[topClassId]) {
                        obj = {
                            topClassId,
                            topClassName,
                            customId: topClassId,
                            materialClassId: topClassId,
                            materialClassName: topClassName,
                            uuid: getUuid(),
                            totalAmount: null,
                            totalQuantity: null
                        }
                        //这里需要改成push多个对象   还没改
                        arr.push(obj)

                        mapObj[topClassId] = obj
                    } else {
                        obj = mapObj[topClassId]
                    }

                    children.push({
                        // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价

                        uuid: getUuid(),
                        billId: this.billId || '',
                        billNo: this.basicFormData.billNo || '',
                        customId: getUuid(),
                        warehouse: e.warehouse,
                        unsettledQuantity: e.unsettledQuantity - 0 + 2, //未结算数量
                        acceptedQuantity: null, //已验收数量
                        changeType: 1,
                        dtlId: '', //加工收料明细id
                        materialClassId: e.materialClassIdArr.join('/'), //物资类别id(
                        materialClassName: e.materialClassNameArr.join('/'), //物资类别名称
                        materialId: e.listId, //物资id
                        materialName: e.materialName, //物资名称
                        settledPrice: 0, //单价
                        quantity: e.surplusQuantity, //数量
                        sourceDtlId: '', //源单明细id
                        spec: e.spec, //规格型号
                        texture: e.texture, //材质
                        unit: e.unit, //计量单位
                        warehouseId: e.warehouseId, //仓库id
                        warehouseName: e.warehouseName, //仓库名称
                        settledQuantity: 0, //结算数量
                        settledAmount: 0, //金额
                        acceptanceAmount: e.acceptanceAmount, //验收金额
                        difference: 0, //差额
                        taxDifference: 0, //税价差额
                        price: e.price || 0
                    })
                    obj.children = !obj.children
                        ? children
                        : obj.children.concat(children)
                    // 统计小计
                    const count = obj.children.reduce(
                        (prev, c) => (prev += c.amount || 0),
                        0
                    )
                    obj.materialName = `小计： ${count}`
                    obj.children = this.uniqueArray(obj.children, 'customId')
                })
                this.wzlbTableData = arr
            })
        },
        //明细数据汇总方法
        uniqueArray (arr, key) {
            const map = new Map()
            return arr.filter(item => {
                const val = item[key] + '' || getUuid()
                return !map.has(val) && map.set(val, 1)
            })
        },
        //我的方法 ↑

        initData () {
            this.getCurrentUnitInfo()
            this.getTurnoverCentralizedPurchaseSummaryGetAgencyListByBillId()
            this.getBasicData()
            this.getTurnoverCentralizedPurchaseSummaryGetSummarySetting() //回去物资汇总明细
        },
        //获取按钮状态
        getCurrentUnitInfo () {
            publicRequest.getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        //根据周材集采汇总id查询申报机构
        getTurnoverCentralizedPurchaseSummaryGetAgencyListByBillId () {
            planRequest
                .turnoverCentralizedPurchaseSummaryGetAgencyListByBillId(
                    this.billId
                )
                .then(res => {
                    this.OrgtableData = res
                    // this.rollUp(res)
                })
        },

        //根据周材集采汇总id查询申报机构
        getTurnoverCentralizedPurchaseSummaryGetSummarySetting () {
            planRequest
                .turnoverCentralizedPurchaseSummaryGetSummarySetting(
                    this.billId
                )
                .then(res => {
                    console.log(res, '当前打印')
                    // this.OrgtableData = res
                    this.notSetData = JSON.parse(JSON.stringify(res)) //没去重之前的数据
                    //去重
                    let children = []
                    res.forEach(item => {
                        item.children.forEach(a => {
                            children.push(a)
                        })
                    })
                    var result = []
                    var obj = {}
                    for (var i = 0; i < children.length; i++) {
                        if (children[i].materialId in obj) {
                            // 相同时肯定不push
                            if (
                                obj[children[i].materialId] !==
                                children[i].texture
                            ) {
                                // 不相同时，判断是否是 '' 和 null，如果是，则表示重复
                                if (
                                    !(
                                        !obj[children[i].materialId] &&
                                        !children[i].texture
                                    )
                                ) {
                                    // 当都不是 '' 和 null 时，才表示不重复，此时才push
                                    result.push(children[i])
                                }
                            }
                        } else {
                            obj[children[i].materialId] = children[i].texture
                            result.push(children[i])
                        }
                        // obj[children[i].amount] = 1
                    }
                    res.forEach(item => {
                        item.uuid = getUuid()

                        item.materialClassName = item.topClassName
                        item.children = result
                        item.children.forEach(v => {
                            v.uuid = getUuid()
                            v.parentId = item.uuid
                        })
                    })
                    console.log(result, 'datadata')
                    this.materialsTableData = res
                })
        },

        //向上汇总
        rollUp (res) {
            res.forEach(item => {
                //拿到 数据 汇总计划金额
                this.basicFormData.amount += item.totalAmount
            })
        },
        //点击图标的时候 获取历史记录
        clickIcon (dtlId, column) {
            this.setHistoryTableData([])
            alert(dtlId)
            planRequest
                .turnoverAnnualDemandPlanGetHistoryList(
                    dtlId,
                    column,
                    this.auditParams.billType
                )
                .then(res => {
                    this.historyTableData = res
                    this.setHistoryTableData(res)
                })
                .catch(e => {
                    alert(e.message)
                })
        },
        // 编辑的时候造历史修改数据结构
        createHistory (row, e) {
            if (row.dtlId) {
                this.createHistoryData.push({
                    historyId: '',
                    modifedName: '',
                    modifiedDate: '',
                    modifiedId: '',
                    opinion: '',
                    sourceId: row.dtlId,
                    sourceValue: 0,
                    updateColumn: e, //修改字段
                    updatedValue: row[e] //修改后的值
                })
            }
        },
        /**
         * 下边几个按钮
         */

        //保存按钮
        async submit () {
            // this.setSelectedInfo(this.wzlbTableData)
            // // 客户端弹窗预览结果
            // // 参数依次为: 打开页面地址、标题、回调函数
            // openAppClient('/showSelectedData', '选择结果', function () {
            //     // alert('关闭后回调')
            // })

            this.formData.amount = this.jiesuanjine - 0
            this.formData.freight = this.yunshufuwufeiyong - 0
            this.formData.taxAmount = this.shuie - 0
            // 是否冲预付款
            this.isOffsetAdvancePayment == true ? this.formData.isOffsetAdvancePayment = 1 : this.formData.isOffsetAdvancePayment = 0
            // 是否冲个人借支
            this.isPersonalBorrowing == true ? this.formData.isPersonalBorrowing = 1 : this.formData.isPersonalBorrowing = 0
            // 是否终期结算
            this.isEndSettle == true ? this.formData.isEndSettle = 1 : this.formData.isEndSettle = 0

            await auditRequest.updatajibenxinxi(this.formData)
            // data = this.billId
            this.theData = this.billId

            //更新明细 ↓
            if (this.wzlbTableData.length > 0) {
                for (let i = 0; i < this.wzlbTableData.length; i++) {
                    if (this.wzlbTableData[i].children.length > 0) {
                        for (
                            let j = 0;
                            j < this.wzlbTableData[i].children.length;
                            j++
                        ) {
                            this.wzlbTableData[i].children[j].billId =
                                this.billId
                            if (
                                this.wzlbTableData[i].children[j].changeType !=
                                -1
                            ) {
                                if (this.Thewas == 'add') {
                                    this.wzlbTableData[i].children[
                                        j
                                    ].changeType = 1
                                } else {
                                    this.wzlbTableData[i].children[
                                        j
                                    ].changeType = 2
                                }
                            }
                        }
                    }
                }
            }
            await auditRequest.updatemingxi(this.wzlbTableData)
            //更新明细 ↑

            //更新服务费用 ↓
            if (this.serviceFeeData.length > 0) {
                for (let i = 0; i < this.serviceFeeData.length; i++) {
                    this.serviceFeeData[i].billId = this.billId
                    if (this.serviceFeeData[i].changeType != -1) {
                        if (this.Thewas == 'add') {
                            this.serviceFeeData[i].changeType = 1
                        } else {
                            this.serviceFeeData[i].changeType = 2
                        }
                    }
                }
            }
            await auditRequest.updatefuwufeiyong(this.serviceFeeData)
            //更新服务费用 ↑

            //更新暂扣保证金 ↓
            if (this.zkbzjtableData.length > 0) {
                for (let i = 0; i < this.zkbzjtableData.length; i++) {
                    this.zkbzjtableData[i].billId = this.billId
                    this.zkbzjtableData[i].returnDepositType = 1
                    if (this.zkbzjtableData[i].changeType != -1) {
                        if (this.Thewas == 'add') {
                            this.zkbzjtableData[i].changeType = 1
                        } else {
                            this.zkbzjtableData[i].changeType = 2
                        }
                    }
                }
            }
            await auditRequest.updatebzj(this.zkbzjtableData)
            //更新暂扣保证金 ↑

            //更新返还保证金 ↓
            if (this.fhbzjtableData.length > 0) {
                for (let i = 0; i < this.fhbzjtableData.length; i++) {
                    this.fhbzjtableData[i].billId = this.billId
                    this.fhbzjtableData[i].returnDepositType = 2
                    if (this.fhbzjtableData[i].changeType != -1) {
                        if (this.Thewas == 'add') {
                            this.fhbzjtableData[i].changeType = 1
                        } else {
                            this.fhbzjtableData[i].changeType = 2
                        }
                    }
                }
            }
            await auditRequest.updatebzj(this.fhbzjtableData)
            //更新返回保证金 ↑
            this.clientPop('suc', '保存成功')
            this.$router.replace('/materialProcurementList')
        },

        // 保存并提交
        async submitCommit () {
            await this.submit()
            await publicRequest.commitexamine({
                billId: this.billId,
                billType: '1020'
            })
            // this.clientPop('suc', '提交成功')
            this.$router.replace('/materialProcurementList')
        },
        //计划明细非空验证
        verifyTable () {
            this.errorMsg = []
            if (this.OrgtableData.length > 0) {
                this.OrgtableData.forEach((n, index) => {
                    if (n.dtls) {
                        n.dtls.forEach(v => {
                            v.children.forEach(item => {
                                if (item.changeType !== -1) {
                                    if (
                                        item.approvalQuantity == '' ||
                                        item.approvalQuantity == null
                                    ) {
                                        let str = `请填写第 ${
                                            index + 1
                                        } 行的核准数量`
                                        this.errorMsg.push(str)
                                    }
                                    if (
                                        item.approvalPrice == '' ||
                                        item.approvalPrice == null
                                    ) {
                                        let str = `请填写第 ${
                                            index + 1
                                        } 行的核准单价`
                                        this.errorMsg.push(str)
                                    }
                                }
                            })
                        })
                    }
                })
            }

            if (this.errorMsg.length > 0) {
                this.isErrorMsg = true
            } else {
                this.isErrorMsg = false
            }
        },
        // nullify () {
        //     //作废
        //     this.setAuditParams(this.nullifyParams)
        //     // 客户端弹窗弹出本地页面
        //     openAppClient('/nullifyDialog', '单据作废原因', () => {
        //         const auditParams = JSON.parse(
        //             localStorage.vuex
        //         ).auditParams
        //         auditRequest.nullify(auditParams).then(() => {
        //             this.clientPop('suc', '作废成功')
        //             this.getCurrentUnitInfo()
        //         })
        //     })
        // },
        //把子列表的数据合并到this.OrgtableData的children
        DoMaterialsTableData () {
            this.OrgtableData.forEach(item => {
                item.changeType = 1
                item.billId = this.billId
            })
        },

        //点击选择 选择申报单位 获取申报机构
        selectUnit () {
            planRequest
                .turnoverCentralizedPurchaseSummaryGetAgencyListByOrgId([
                    '1505122036192309249'
                ])
                .then(res => {
                    this.OrgtableData = res
                    this.DoMaterialsTableData() //给数据造billid 和 chengetype
                    this.isCollect = true
                })
        },
        //点击申报单位列表点击编号显示对应子列表
        tableDbShow (row, column) {
            row.dtls = []
            if (column.label === '年度需用计划编号') {
                if (row.changeType == 1) {
                    planRequest
                        .turnoverCentralizedPurchaseSummaryGetAllMaterial(
                            row.annualDemandPlanBillId
                        )
                        .then(res => {
                            this.OrgSonTableData = res
                            this.OrgSonTableData.forEach(item => {
                                item.changeType = 1
                                item.uuid = getUuid()
                                item.materialClassName = item.topClassName

                                item.children.forEach(v => {
                                    v.changeType = 1
                                    v.parentId = item.uuid
                                    v.uuid = getUuid()
                                })
                                row.dtls.push(item)
                            })
                        })
                } else {
                    planRequest
                        .turnoverCentralizedPurchaseSummaryGetMaterial(
                            row.dtlId
                        )
                        .then(res => {
                            this.OrgSonTableData = res
                            this.OrgSonTableData.forEach(item => {
                                item.uuid = getUuid()
                                item.materialClassName = item.topClassName
                                row.dtls.push(item)
                                item.children.forEach(v => {
                                    v.changeType = 2
                                    v.parentId = item.uuid
                                    v.uuid = getUuid()
                                })
                            })
                        })
                }
            }
        },
        // 点击子表的选择明细
        selectDetails () {
            console.log('选择明细')
        },
        //点击集中采购单位 选择单位

        clickPurchasingUnit (row) {
            selectDataClient()
            // 弹窗选择数据
            selectDataClient({
                SelectServiceToken: '/hr/org/getChildrenOrg', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '选择全集团组织机构数据', // 标题
                InitParamsStr: JSON.stringify({
                    orgId: this.basicFormData.orgId
                }) //参数
            }).then(val => {
                const orgData = val[0] //获取客户端返回的数据
                row.purchasingUnitId = orgData.orgId
                row.purchasingUnitName = orgData.orgName
                row.changeType === 1
                    ? this.count_(row, 1)
                    : this.count_(row, 2) //判断当前的状态是新增还是修改
                // 保存用户选择返回数据到store
                this.setSelectedInfo(val)
                // 客户端弹窗预览结果
                // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     alert('关闭后回调')

                // })
            })
        },
        //点击物资汇总的物资名称，汇总物资下的所有机构
        showA (row) {
            console.log(row, 'row')
            console.log(this.notSetData, 'this.notSetData')
            this.materialsNameData = []
            this.notSetData.forEach(item => {
                item.children.forEach(b => {
                    if (row.materialId === b.materialId) {
                        // const obj = {
                        //     orgName: item.orgName,
                        //     materialName: b.materialName,
                        //     spec: b.spec,
                        //     unit: b.unit,
                        //     texture: b.texture,
                        //     planQuantity: b.planQuantity,
                        //     marketPrice: '',
                        //     amount: b.amount
                        // }
                        // this.materialsNameData = []
                        this.materialsNameData.push(b)
                    }
                })
            })
        },
        //申报机构汇总-删除 申报机构汇总表格明细
        deleteMaterials () {
            if (this.planSelect.length > 0) {
                this.OrgtableData.forEach(v => {
                    this.planSelect.forEach(item => {
                        if (item.dtlId && item.dtlId === v.dtlId) {
                            v.changeType = -1
                        }
                    })
                })
            }
            if (this.planSelect.length > 0) {
                this.planSelect.forEach(item => {
                    if (item.dtlId) {
                        const newArr = []
                        newArr.push(item)
                        newArr.forEach(item => {
                            this.$set(item, 'changeType', -1)
                        })

                        // this.$refs.multipleTable.clearSelection()
                    } else {
                        const localArr = []
                        localArr.push(item)
                        for (let i = this.OrgtableData.length; i > 0; i--) {
                            for (let j = 0; j < localArr.length; j++) {
                                if (this.OrgtableData[i - 1] === localArr[j]) {
                                    this.OrgtableData.splice(i - 1, 1)
                                }
                            }
                        }
                        // this.$refs.multipleTable.clearSelection()
                    }
                })
            }
            console.log(this.OrgtableData)
        },

        //监听明细 机构汇总表格 数据input事件 判断用户是否修改  ，计算金额
        countInput (row) {
            row.changeType === 1 ? this.count_(row, 1) : this.count_(row, 2)
            console.log(this.materialsTableData, '物资汇总')
        },
        // 汇总逻辑
        count_ (row, num) {
            row.changeType = num
            this.basicFormData.amount = null

            row.approvalAmount = row.approvalQuantity * row.approvalPrice
            this.OrgtableData.forEach(item => {
                console.log(item, '逻辑汇总')
                item.changeType = num
                this.basicFormData.amount += item.totalAmount =
                    row.approvalAmount //把汇总的金额给父级 方便汇总计算
                if (item.children) {
                    item.children.forEach(i => {
                        i.changeType = num
                    })
                }
            })
        },
        //申报机构汇总-明细子列表删除按钮
        deleteEle (row) {
            row.changeType = -1
            this.OrgtableData.forEach(item => {
                item.changeType = 2
                if (item.dtls) {
                    item.dtls.forEach(v => {
                        if (v.children) {
                            const data = v.children.find(i => {
                                return i.dtlId === row.dtlId
                            })
                            data.changeType = -1
                        }
                    })
                }
            })
        },
        //获取集采汇总id获取基本信息
        getBasicData () {
            planRequest
                .turnoverCentralizedPurchaseSummaryFindById(this.billId)
                .then(res => {
                    this.basicFormData = res
                })
        },
        //删除提示框
        ctDelete () {
            showPromptPop(
                '确定要删除吗？删除的数据可以在【回收站】还原或彻底删除。'
            )
        },
        //根据集采汇总id删除单据
        delData () {
            planRequest
                .turnoverCentralizedPurchaseSummaryDelete(this.billId)
                .then(res => {
                    if (res.code == 200) {
                        showSuccessPop('删除成功！')
                        this.isSkip = true
                    }
                    this.$router.push('./revolveCollectList')
                })
        },
        handleFullScreen () {
            this.fullscreen = !this.fullscreen
        },
        //查询附件信息
        getAttach () {
            this.objFlag.flag5 = true
        },
        //申报机构删除逻辑
        tableRowClassName ({ row }) {
            if (row.changeType === -1) {
                return 'warning-row'
            }
            return ''
        },
        //获取用户在 汇总明细-申报机构汇总 表格的已选择项
        planTableSelect (selection) {
            this.planSelect = selection
        },
        //取消
        handleClose () {
            // this.dialogVisible = false
            this.$router.replace('/materialProcurementList')
        },
        onChangeTab (e) {
            const height  = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            this.clickId = e.name //记录每次点击的id
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('evaluateCon')) {
                    const lastConHeight =
                        document.getElementById('evaluateCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    console.log('this.lastConHeight', this.lastConHeight)
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },

        // 源单编号-跳转到对应的详情页
        sourceBillNoClick () {
            let url = ''
            let name = ''
            switch (this.formData.businessType) {
            case 0:
                url = '/sporadicPurchaseParticulars'
                name = '查看零星采购计划'
                break
            case 1:
                url = '/ctMaterialApplyShow'
                name = '查看物资采购合同'
                break
            case 2:
                url = '/interiorAllotEetails'
                name = '查看内部调拨'
                break
            }
            openAppClient(
                `${url}?billid=${this.formData.sourceBillId}&isview=${true}`,
                `${name}`
            )
        },

        // 点击验收编号,查看验收单
        acceptanceBillNoClick () {
            openAppClient(
                `/goodsCheckDetails?isview=${true}&billid=${
                    this.formData.acceptanceBillId
                }`,
                '查看物资验收'
            )
        },
        // 打印
        async print (value) {
            const printData = async ()=>{
                showLoading()
                try{
                    const  params =  {
                        'reportTitle': '', //报表名
                        'orgName': this.formData.orgName, //单据机构
                        'reportQRUri': '', //报表内容URI
                        'billNo': this.formData.billNo, //单据编码
                        'summaryInfoItems': [], //基本信息
                        'tables': [] //表格
                    }
                    const reportTitle = this.commandList.find(item => item.key === value)
                    params.reportTitle = reportTitle.value
                    let tableObj = {}
                    if(reportTitle.key === 1 || reportTitle.key === 2) {
                        tableObj = {
                            1: this.SettlementPrn(),
                            2: this.MarginPrn(),
                        }
                    }else {
                        tableObj = {
                            1: this.SettlementPrn(),
                            2: this.MarginPrn(),
                            3: this.servPrn(),
                        }
                    }
                    const tableData = tableObj[reportTitle.key]
                    // tableData是获取到的对象/数组
                    console.log('tableData', tableData)
                    params.summaryInfoItems = tableData.basicInfo
                    params.tables.push(tableData.tableList)
                    if(tableData.theScndTbl) {
                        params.tables.push(tableData.theScndTbl)
                    }
                    params.tables.push(await this.prnAuditHst())
                    console.log('params', params)
                    hideLoading()
                    return params
                }catch(err) {
                    console.log(err)
                    // this.clientPop('err', '打印失败')
                    hideLoading()
                }
            }
            const data = await printData()
            webprintReport(data)
        },
        // 物资结算单
        SettlementPrn () {
            const basicInfo = []
            const data = this.formData
            const list = [
                ['供货单位', data.settlementUnitName, false],
                ['附件', '    ' + '张', false],
                ['结算依据', data.sourceBillNo, false],
                ['发票编号', data.invoiceNo, false],
                ['结算日期', data.settlementDate, false],
                ['不含税金额(元)', data.amount, false],
                ['税率(%)', data.taxRate + '%', false],
                ['可抵扣税额(元)', data.taxAmount, false],
                ['价税合计金额(元)', data.totalAmount, false],
                ['结算差额', data.difference, false],
                ['税额差额(元)', data.taxDifference, false],
                ['冲预付款金额(元)', data.offsetAdvancePayment, false],
                ['累计结算金额(元)', data.currentTotalAmount, false],
                ['终期结算', data.isEndSettle ? '是' : '否', false],
                ['价税合计金额大写', numToChinese(Math.abs(data.totalAmount)), true],
                ['备注信息', data.remarks, true],
            ]
            list.forEach(item => {
                const obj = {
                    label: '标题',
                    value: '内容',
                    isFullRow: false, // 是否占整行
                }
                obj.label = item[0]
                obj.value = item[1]
                obj.isFullRow = item[2]
                basicInfo.push(obj)
            })
            // 表格数据
            let newArr = this._.cloneDeep(this.wzlbTableData)
            let lastArr = []
            newArr.forEach(item => {
                lastArr.push(item)
                if(item.children.length > 0) {
                    lastArr.push(...item.children)
                }
            })
            const tableList = {
                'tableTitle': '结算明细',
                'tableContent': {
                    '物资类别': 'materialClassName',
                    '物资名称': 'materialName',
                    '规格': 'spec',
                    '材质': 'texture',
                    '单位': 'unit',
                    '结算数量': 'settledQuantity',
                    '验收单价(元)': 'acceptancePrice',
                    '验收金额(元)': 'acceptanceAmount',
                    '结算单价(元)': 'settledPrice',
                    '结算金额(元)': 'settledAmount',
                    '差额(元)': 'difference',
                },
                'tableData': lastArr, //表格数据
            }
            return { basicInfo, tableList }
        },
        // 服务费结算单
        servPrn () {
            if(this.serviceFeeData.length > 0) {
                if(this.serviceFeeList.length < 1) {
                // 是否相同结算单位
                    const isTheSm = this.serviceFeeData.some(item =>this.serviceFeeData[0].settlementUnitId !== item.settlementUnitId)
                    // 是否相同税率
                    const isSmRt = this.serviceFeeData.some(item =>this.serviceFeeData[0].taxRate !== item.taxRate)
                    if(isTheSm || isSmRt) {
                        this.clientPop('err', '需选择相同结算单位和相同税率的数据,请先选择!')
                        return
                    }else {
                    // 如果都是相同结算单位并且相同税率
                        this.serviceFeeList = this.serviceFeeData
                        const obj = this.serviceFeeData.reduce((prev, c) => {
                            prev.amount += +(+c.amount).toFixed(2),
                            prev.totalAmount += +(+c.totalAmount).toFixed(2),
                            prev.taxAmount += +(+c.taxAmount).toFixed(2)
                            return prev
                        }, { amount: 0, totalAmount: 0, taxAmount: 0, })
                        obj.settlementUnitName = this.serviceFeeData[0].settlementUnitName
                        obj.contractBillNo = this.serviceFeeData[0].contractBillNo
                        obj.taxRate = this.serviceFeeData[0].taxRate
                        return this.servPrnSelectFn(obj)
                    }
                }else {
                // 是否相同结算单位
                    const isTheSm = this.serviceFeeList.some(item =>this.serviceFeeList[0].settlementUnitId !== item.settlementUnitId)
                    // 是否相同税率
                    const isSmRt = this.serviceFeeList.some(item =>this.serviceFeeList[0].taxRate !== item.taxRate)
                    if(isTheSm || isSmRt) {
                        this.clientPop('err', '需选择相同结算单位和相同税率的数据,请先选择!')
                        return
                    }else {
                    // 如果都是相同结算单位并且相同税率
                        const obj = this.serviceFeeList.reduce((prev, c) => {
                            prev.amount += +(+c.amount).toFixed(2),
                            prev.totalAmount += +(+c.totalAmount).toFixed(2),
                            prev.taxAmount += +(+c.taxAmount).toFixed(2)
                            return prev
                        }, { amount: 0, totalAmount: 0, taxAmount: 0, })
                        obj.settlementUnitName = this.serviceFeeList[0].settlementUnitName
                        obj.contractBillNo = this.serviceFeeList[0].contractBillNo
                        obj.taxRate = this.serviceFeeList[0].taxRate
                        return this.servPrnSelectFn(obj)
                    }
                }
            }else {
                this.clientPop('err', '服务费用无明细可打印')
                return
            }
        },
        servPrnSelectFn (obj) {
            const basicInfo = []
            const data = this.formData
            const list = [
                ['服务单位', obj.settlementUnitName, false],
                ['附件', '    ' + '张', false],
                ['结算依据', obj.contractBillNo, false],
                ['结算日期', data.settlementDate, false],
                ['本期结算合计', obj.amount, false],
                ['税率(%)', obj.taxRate + '%', false],
                ['可抵扣税额合计(元)', obj.taxAmount, false],
                ['税价合计金额(元)', obj.totalAmount, false],
                ['冲预付款(元)', data.offsetAdvancePayment, false],
                ['累计结算金额(元)', obj.currentTotalAmount, false],
                ['税价合计金额大写', numToChinese(Math.abs(obj.totalAmount)), true],
                ['备注信息', data.remarks, true],
            ]
            list.forEach(item => {
                const obj = {
                    label: '标题',
                    value: '内容',
                    isFullRow: false, // 是否占整行
                }
                obj.label = item[0]
                obj.value = item[1]
                obj.isFullRow = item[2]
                basicInfo.push(obj)
            })
            // 表格数据
            const tableList = {
                'tableTitle': '服务费明细',
                'tableContent': {
                    '清单名称': 'contractDtlName',
                    '结算单位': 'settlementUnitName',
                    '发票编号': 'invoiceNo',
                    '数量': 'quantity',
                    '单价': 'price',
                    '金额': 'amount',
                    '税率': 'taxRate',
                    '税额': 'taxAmount',
                    '税额合计': 'totalAmount',
                },
                'tableData': this.serviceFeeList, //表格数据
            }
            return { basicInfo, tableList }
        },
        // 保证金打印
        MarginPrn () {
            const basicInfo = []
            const data = this.formData
            const list = [
                ['供应商', data.settlementUnitName, false],
                ['附件', '    ' + '张', false],
                ['结算依据', data.sourceBillNo, false],
                ['结算日期', data.settlementDate, false],
                ['发票编号', data.invoiceNo, false],
            ]
            list.forEach(item => {
                const obj = {
                    label: '标题',
                    value: '内容',
                    isFullRow: false, // 是否占整行
                }
                obj.label = item[0]
                obj.value = item[1]
                obj.isFullRow = item[2]
                basicInfo.push(obj)
            })
            // 暂扣保证金
            const tableList = {
                'tableTitle': '暂扣保证金',
                'tableContent': {
                    '名称': 'returnDepositName',
                    '暂扣保证金(元)': 'amount',
                    '截止上期末暂扣保证金(元)': 'previousTotalAmount',
                    '截止本期末暂扣保证金(元)': 'currentTotalAmount',
                    '说明': 'remarks',
                },
                'tableData': this.zkbzjtableData, //表格数据
            }
            // 返还保证金
            const theScndTbl = {
                'tableTitle': '返还保证金',
                'tableContent': {
                    '名称': 'returnDepositName',
                    '返还保证金(元)': 'amount',
                    '截止上期末返还保证金(元)': 'previousTotalAmount',
                    '截止本期末返还保证金(元)': 'currentTotalAmount',
                    '说明': 'remarks',
                },
                'tableData': this.fhbzjtableData, //表格数据
            }
            return { basicInfo, tableList, theScndTbl }
        },
        // 审核历史
        async prnAuditHst () {
            const historyTable  = await publicRequest.getauditHistory({
                billId: this.billId,
                billType: 1020,
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            })
            const historyList = {
                'tableTitle': '审核历史',
                'tableContent': {
                    '审核级次': 'unitName',
                    '审核人': 'assignUser',
                    '审核人岗位': 'userTitle',
                    '通知时间': 'notifyTime',
                    '审核时间': 'completeTime',
                    '审核意见': 'opinion',
                },
                'tableData': historyTable, //表格数据
            }
            return historyList
        }
    },
    computed: {
        ...mapState({
            options: state => state.contract.ctClassify,
            popConfirm: 'popConfirm',
            popStatus: 'popStatus',
            userInfo: state => state.userInfo,
            currencyForm: state => state.equip.equipData.currencyForm, //币种
            state: state => state.equip.equipData.state //通用流程状态
        }),
        redBillStateFun () {
            let redState = ''
            switch (this.formData.redBillState) {
            case 0:
                redState = '冲销中'
                break
            case 1:
                redState = '冲销中'
                break
            case 2:
                redState = '已冲销'
                break
            case 3:
                redState = '红单'
                break
            }
            return redState
        },
        //my ↓
        shuie () {
            // taxAmount
            if (this.formData.taxAmount == 0) {
                if (this.jiesuanjine > 0 && this.formData.taxRate > 0) {
                    return this.jiesuanjine * (this.formData.taxRate / 100)
                } else {
                    return 0
                }
            } else {
                return this.formData.taxAmount
            }
        },
        jiesuanjine () {
            // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
            if (this.formData.amount == 0) {
                if (this.wzlbTableData.length > 0) {
                    let num = 0
                    for (let i = 0; i < this.wzlbTableData.length; i++) {
                        if (this.wzlbTableData[i].children.length > 0) {
                            for (
                                let j = 0;
                                j < this.wzlbTableData[i].children.length;
                                j++
                            ) {
                                num +=
                                    this.wzlbTableData[i].children[j]
                                        .settledAmount - 0 || 0
                            }
                        }
                    }
                    return num
                } else {
                    return 0
                }
            } else {
                return this.formData.amount
            }
        },
        // my ↑
        yunshufuwufeiyong () {
            if (this.freight != 0) {
                if (this.serviceFeeData.length > 0) {
                    let num = 0
                    for (let i = 0; i < this.serviceFeeData.length; i++) {
                        num += this.serviceFeeData[i].totalAmount
                    }
                    return num
                } else {
                    return 0
                }
            } else {
                return 0
            }
        },
        judgeRoute () {
            if (this.$route.path.includes('Add')) {
                return false
            }
            return true
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        },
        attachId () {
            return this.billId
        },
        // statusLable () {
        //     return param => {
        //         const state = this.$store.state.equip.equipData.state
        //         const obj = state.find(x => x.value == param)

        //         if (obj !== undefined) {
        //             return obj.label
        //         }
        //     }
        // }
    },

    mounted () {
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        const arr = [
            'baseInfo',
            'planDetail',
            'fwfy',
            'bzj',
            'accessory',
            'auditHistory'
        ]
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //当点击的tab有子tab时做滚动逻辑
            if (this.clickTabFlag && arr.find(x => x === this.clickId)) {
                this.childTabClass = '' //无子tab时清空tab的类名
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    let itemTop
                    let arr
                    if (item instanceof Array) {
                        const prevHeight = document.getElementById(
                            item[0]
                        ).offsetHeight //因这里一个选项有两个表格，需获取前一个表格的高度进行计算
                        arr = item.map((x, i) => {
                            if (i === 0) {
                                return document.getElementById(x).offsetTop
                            } else {
                                return (
                                    document.getElementById(x).offsetTop +
                                    prevHeight +
                                    document.getElementById(item[0]).offsetTop
                                )
                            }
                        })
                        return arr
                    } else {
                        itemTop = document.getElementById(item).offsetTop
                        return itemTop
                    }
                })
            }
            const scrollTop =
                document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            let curLocalChild = 1
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                if ($idsTop[i] instanceof Array) {
                    let item = $idsTop[i]
                    for (let lenth = item.length, j = lenth - 1; j >= 1; j--) {
                        let itemChild = $idsTop[i][j]
                        if (scrollTop + 1 >= itemChild) {
                            curLocalChild = j
                            break
                        }
                    }
                    if (scrollTop + 1 >= item[0]) {
                        curLocal = i
                        break
                    }
                } else {
                    let item = $idsTop[i]
                    if (scrollTop + 1 >= item) {
                        curLocal = i
                        break
                    }
                }
            }
            // 设置对应tabName
            if (arr[curLocal] instanceof Array) {
                this.tabsName = arr[curLocal][0]
                this.tabsNameChild = arr[curLocal][curLocalChild]
            } else {
                this.tabsName = arr[curLocal]
            }
            // //动态改变二级选项卡类名
            // arr.forEach((item, index) => {
            //     if (item instanceof Array) {
            //         let tabNavHeight = document.querySelector('.childTab .el-tabs__nav')
            //             ? document.querySelector('.childTab .el-tabs__nav').offsetHeight
            //             : 0
            //         if (scrollTop + 1 >= $idsTop[index + 1] - tabNavHeight) {
            //             this.childTabClass = 'childTab2'
            //         } else if (scrollTop <= $idsTop[index][1]) {
            //             this.childTabClass = ''
            //         } else {
            //             this.childTabClass = 'childTab1'
            //         }
            //     }
            // })
        })
        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                let itemTop
                let arr
                if (item instanceof Array) {
                    const prevHeight = document.getElementById(
                        item[0]
                    ).offsetHeight //因这里一个选项有两个表格，需获取前一个表格的高度进行计算
                    arr = item.map((x, i) => {
                        if (i === 0) {
                            return document.getElementById(x).offsetTop
                        } else {
                            return (
                                document.getElementById(x).offsetTop +
                                prevHeight +
                                document.getElementById(item[0]).offsetTop
                            )
                        }
                    })
                    return arr
                } else {
                    itemTop = document.getElementById(item).offsetTop
                    return itemTop
                }
            })
        })
    }
}
</script>

<style lang="scss" scoped>
.lll {
    width: 100%;
    height: 30px;
    line-height: 30px;
    background: #f2f2f2;
    padding-right: 20px;
    padding-left: 20px;
}
.buttons {
    left: 0;
}
.e-form {
    margin-bottom: 80px;
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}

.e-table {
    background: #fff;
}
::v-deep.el-table .warning-row {
    display: none;
}
// ::v-deep.el-table__body-wrapper::-webkit-scrollbar{
//      width: 6px !important; // 横向滚动条
//     height: 10px !important// 纵向滚动条
// }

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
    width: 6px; // 横向滚动条
    height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 5px;
}
::v-deep.el-table .warning-row {
    display: none;
}
.el-tab-pane {
    margin-left: -10px;
}
.childTab {
    ::v-deep .el-tabs__header {
        position: absolute !important;
    }
    ::v-deep .el-tabs__content {
        padding: 0 0 0 20px !important;
    }
}
.childTab1 {
    ::v-deep .el-tabs__header {
        position: absolute !important;
        .el-tabs__nav-scroll {
            position: relative;
            .el-tabs__nav {
                position: fixed;
                top: 0;
                width: 190px;
            }
        }
    }
}
.childTab2 {
    ::v-deep .el-tabs__header {
        position: absolute !important;
        .el-tabs__nav-scroll {
            position: relative;
            .el-tabs__nav {
                position: absolute;
                bottom: 0;
                width: 100%;
            }
        }
    }
}
::v-deep .el-dropdown .el-button-group .el-button {
    margin-right: 0px;
    border: 0;
}
::v-deep .el-dropdown .el-button-group :nth-child(2) {
    margin-right: 5px;
}
::v-deep .el-dropdown .el-dropdown__caret-button::before {
    background-color: #2e61d7;
}
</style>
